package cn.edu.java.stream.functionalinterface;

import java.util.function.BinaryOperator;

public class BinaryOperatorDemo {
    public static void main(String[] args) {
        BinaryOperator<Integer> sum = new BinaryOperator<Integer>() {
            @Override
            public Integer apply(Integer a, Integer b) {
                return a + b;
            }
        };

        int result = sum.apply(2, 3);
        System.out.println(result);  // 输出: 5


        BinaryOperator<Integer> sum2 = (a, b) -> a + b;

        int result2 = sum2.apply(2, 3);
        System.out.println(result2);  // 输出: 5

    }
}
